package com.xzqwjw.taskmanager.activity;

import java.util.Date;
import java.util.List;
import java.util.Map;

import com.leaderinfo.model.InfoContact;
import com.leaderinfo.model.InfoEducation;
import com.leaderinfo.model.InfoExpertise;
import com.leaderinfo.model.InfoFamily;
import com.leaderinfo.model.InfoPartyBasic;
import com.leaderinfo.model.InfoPhoto;
import com.leaderinfo.model.InfoUnit;
import com.leaderinfo.utility.Utility;
import com.xzqwjw.taskmanager.R;

import android.annotation.SuppressLint;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.KeyEvent;
import android.view.View;
import android.view.View.OnClickListener;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.TextView;

public class ActivityShowInfo extends Activity implements OnClickListener {

  final String mimeType = "text/html";
  final String encoding = "utf-8";

  private WebView objWV;

  private String strDBFile = "";
  private int intAID = 0;

  private TextView tvRealName;
  private TextView tvSex;
  private TextView tvBirthday;
  private TextView tvNation;
  private TextView tvNativePlace;
  private TextView tvBirthPlace;

  private ImageView ivHeadPhoto;

  private ImageButton imgbtnFavorite;

  private Map<String, Object> mapInfo = null;
  private InfoPartyBasic objPartyBasicInfo = null;

  @SuppressLint("SetJavaScriptEnabled")
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_show_info);

    Intent objIT = getIntent();
    strDBFile = objIT.getStringExtra("DBFilePath");
    intAID = Integer.parseInt(objIT.getStringExtra("AID"));

    // 时间格式转换用到的临时变量
    Date dateTemp;

    com.leaderinfo.dao.PartyInfoDao objDaoPartyInfo = new com.leaderinfo.dao.PartyInfoDao(strDBFile);

    // int intAID = 310;

    objWV = (WebView) findViewById(R.id.wvShowInfo);

    tvRealName = (TextView) findViewById(R.id.tvRealName);
    tvSex = (TextView) findViewById(R.id.tvSex);
    tvBirthday = (TextView) findViewById(R.id.tvBirthday);
    tvNation = (TextView) findViewById(R.id.tvNation);
    tvNativePlace = (TextView) findViewById(R.id.tvNativePlace);
    tvBirthPlace = (TextView) findViewById(R.id.tvBirthPlace);

    imgbtnFavorite = (ImageButton) findViewById(R.id.imgbtnFavorite);
    imgbtnFavorite.setOnClickListener(this);
    if (objDaoPartyInfo.getFavoriteFlag(intAID) == 0) {
      imgbtnFavorite.setImageDrawable(this.getResources().getDrawable(R.drawable.bgbtn_favorite_add));
    } else {
      imgbtnFavorite.setImageDrawable(this.getResources().getDrawable(R.drawable.bgbtn_favorite_cancel));
    }

    ivHeadPhoto = (ImageView) findViewById(R.id.ivHeadPhoto);

    mapInfo = objDaoPartyInfo.getRecordByAID(intAID);

    if (mapInfo != null) {
      objPartyBasicInfo = (InfoPartyBasic) mapInfo.get("PartyInfo");
    }

    tvRealName.setText(objPartyBasicInfo.RealName);
    tvSex.setText(objPartyBasicInfo.Sex);

    String strBirthday = objPartyBasicInfo.Birthday;
    strBirthday = Utility.setCNDate(strBirthday);
    tvBirthday.setText(strBirthday);

    tvNation.setText(objPartyBasicInfo.Nation);
    tvNativePlace.setText(objPartyBasicInfo.NativePlace);
    tvBirthPlace.setText(objPartyBasicInfo.BirthPlace);

    // 得到头像二进制数据
    Map<String, Object> mapPhoto = null;
    InfoPhoto objPhoto = null;
    byte[] aryPhotoData = null;
    com.leaderinfo.dao.PhotoDao objPhotoDAO = new com.leaderinfo.dao.PhotoDao(strDBFile);
    mapPhoto = objPhotoDAO.getRecordByBasicID(intAID);
    if (!(mapPhoto == null)) {
      objPhoto = (InfoPhoto) mapPhoto.get("PhotoInfo");
      aryPhotoData = objPhoto.PhotoData;
    }

    ivHeadPhoto.setImageBitmap(Utility.zoomBMP(Utility.setBytesToBMP(aryPhotoData, null), 300, 400));

    // 设置WebView属性，能够执行Javascript脚本
    WebSettings webSettings = objWV.getSettings();
    webSettings.setJavaScriptEnabled(true);
    webSettings.setDefaultTextEncodingName("UTF-8");

    // 加载需要显示的网页
    String strHtml = getHtmlByPartyID(intAID);
    // 载入这个html页面
    // 下面这种转载方式中文显示有问题
    // objWV.loadData(strHtml, "text/html", "UTF-8");
    // 显示图片用下面这句
    // objWV.loadDataWithBaseURL(baseUrl, strHtml, "text/html", "UTF-8",
    // null);
    objWV.loadDataWithBaseURL(null, strHtml, "text/html", "UTF-8", null);
  }

  private String getHtmlByPartyID(int intPartyID) {
    String strHtml = "";

    String strHtmlHead = "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\""
        + "\"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">"
        + "<html xmlns=\"http://www.w3.org/1999/xhtml\">" + "<head>"
        + "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" />"
        + "<title>干部职工详细信息</title>" + "<style type=\"text/css\">" + "* { margin:0; padding:0; }"
        + "body { padding:10px; line-height:160%; color:#397387; }"
        + "table { border-top:1px solid #397387; border-right:1px solid #397387; margin:10px 0 0 0; }"
        + "td { border-bottom:1px solid #397387; border-left:1px solid #397387; }"
        + "td { padding:8px 5px; font-size:16px; color:#408090; }"
        + ".atitle { text-align:center; font-size:22px; padding:20px; background:#397387; color:#9DD7E5; }"
        + ".atab { text-align:center; background:#9DD7E5; color:#397387; font-size:18px; }"
        + "</style></head><body>";

    String strHtmlFoot = "</body></html>";

    strHtml = strHtmlHead;

    strHtml += setHtmlBasic(intPartyID);
    // strHtml += setHtmlEdu(intPartyID);
    // strHtml += setHtmlFamily(intPartyID);
    // strHtml += setHtmlUnit(intPartyID);

    strHtml += strHtmlFoot;

    strHtml = strHtml.replaceAll("\r", "<br />");
    strHtml = strHtml.replaceAll("\n", "<br />");
    strHtml = strHtml.replaceAll("\r\n", "<br />");
    return strHtml;
  }

  // 设置基本信息的html代码
  private String setHtmlBasic(int intBasicID) {
    // 政治面貌
    String strZZMM = (objPartyBasicInfo.Party1Name.equals("")) ? "&nbsp;" : objPartyBasicInfo.Party1Name;
    // 参加工作时间
    String strWorkTime = objPartyBasicInfo.WorkTime;
    strWorkTime = Utility.setCNDate(strWorkTime);
    strWorkTime = (strWorkTime.equals("")) ? "&nbsp;" : strWorkTime;
    // 专长
    String strExpertise = (objPartyBasicInfo.Expertise.equals("")) ? "&nbsp;" : objPartyBasicInfo.Expertise;
    // 健康状况
    String strHealth = (objPartyBasicInfo.Health.equals("")) ? "&nbsp;" : objPartyBasicInfo.Health;
    // 婚姻状况
    String strMarriage = (objPartyBasicInfo.RelationUnit.equals("")) ? "&nbsp;" : objPartyBasicInfo.RelationUnit;
    // 获取学历
    String[] aryEduInfo = GetEduInfo(intBasicID);
    // 全日制学历
    String strEducation1 = aryEduInfo[1];
    // 在职学历
    String strEducation2 = aryEduInfo[0];
    // 身份证号
    String strIDCard = (objPartyBasicInfo.CardNumberID.equals("")) ? "&nbsp;" : objPartyBasicInfo.CardNumberID;
    // 手机号码
    String strPhoneMobile = "";
    com.leaderinfo.dao.ContactDao objContactDAO = new com.leaderinfo.dao.ContactDao(strDBFile);
    mapInfo = objContactDAO.getRecordByBasicID(intBasicID);
    InfoContact objContactInfo = null;
    if (mapInfo != null) {
      objContactInfo = (InfoContact) mapInfo.get("ContactInfo");
    }
    if (objContactInfo != null) {
      strPhoneMobile = (objContactInfo.PhoneMobile.equals("")) ? "&nbsp;" : objContactInfo.PhoneMobile;
    }

    // 获取工作单位及职务信息
    InfoUnit objUnitInfo = new InfoUnit();
    com.leaderinfo.dao.UnitDao objUnitDAO = new com.leaderinfo.dao.UnitDao(strDBFile);
    com.leaderinfo.dao.UnitCategoryDao objUnitCategoryDAO = new com.leaderinfo.dao.UnitCategoryDao(strDBFile);

    InfoExpertise objExpertiseInfo = new InfoExpertise();
    com.leaderinfo.dao.ExpertiseDao objExpDAO = new com.leaderinfo.dao.ExpertiseDao(strDBFile);

    Map<String, Object> mapUnitInfo = objUnitDAO.getRecordByBasicID(intBasicID);
    Map<String, Object> mapExpertiseInfo = objExpDAO.getRecordByBasicID(intBasicID);
    // 单位名称
    String strUnitName = "";
    // 岗位类别HoldpostReferenceNumber
    String strGWLB = "";
    // 职称级别WorkContent
    int intJobLevelID = 0;
    String strJobLevel = "";
    // 职务名称
    String strJobName = "";
    // 专业技术任职资格QualificationsName
    String strQualificationsName = "";
    // 职务级别（行政层次）AppointmentCategory
    String strGOVLevel = "";

    if (mapUnitInfo != null) {
      objUnitInfo = (InfoUnit) mapUnitInfo.get("UnitInfo");
      if (objUnitInfo.UnitID > 0) {
        strUnitName = objUnitCategoryDAO.getUnitNameByID(objUnitInfo.UnitID);
      }
      strJobName = (objUnitInfo.JobName.equals("")) ? "&nbsp;" : objUnitInfo.JobName;
      // intJobLevelID = objUnitInfo.JobLevelID;
      // strJobLevel = GetJobLevelName(intJobLevelID);
      strJobLevel = objUnitInfo.WorkContent;
      strJobLevel = (strJobLevel.equals("")) ? "&nbsp;" : strJobLevel;
      strGWLB = (objUnitInfo.HoldpostReferenceNumber.equals("")) ? "&nbsp;" : objUnitInfo.HoldpostReferenceNumber;
      // strGOVLevel = GetGOVLevelName(objUnitInfo.WorkContent);
      strGOVLevel = objUnitInfo.AppointmentCategory;
      strGOVLevel = (strGOVLevel.equals("")) ? "&nbsp;" : strGOVLevel;
    }

    if (mapExpertiseInfo != null) {
      objExpertiseInfo = (InfoExpertise) mapExpertiseInfo.get("ExpertiseInfo");
      strQualificationsName = (objExpertiseInfo.QualificationsName.equals("")) ? "&nbsp;"
          : objExpertiseInfo.QualificationsName;
    }
    // 简历
    String strResume = (objPartyBasicInfo.Resume.equals("")) ? "&nbsp;" : objPartyBasicInfo.Resume;

    // 设置HTML代码
    String strHtml = "<table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">"
        + "<tr><td colspan=\"4\" class=\"atitle\">干部职工信息</td></tr>"

        + "<tr><td width=\"20%\" class=\"atab\">政治面貌</td>" + "<td width=\"30%\">" + strZZMM + "</td>"
        + "<td width=\"20%\" class=\"atab\">参加工作<br />时　　间</td>" + "<td width=\"30%\">" + strWorkTime
        + "</td></tr>"

        + "<tr><td class=\"atab\">婚姻状况</td><td>" + strMarriage + "</td>" + "<td class=\"atab\">健康状况</td><td>"
        + strHealth + "</td></tr>"

        + "<tr><td class=\"atab\">全日制学历</td><td>" + strEducation1 + "</td>" + "<td class=\"atab\">在职学历</td><td>"
        + strEducation2 + "</td></tr>"

        + "<tr><td class=\"atab\">身份证号</td><td>" + strIDCard + "</td>" + "<td class=\"atab\">手机号码</td><td>"
        + strPhoneMobile + "</td></tr>"

        + "<tr><td class=\"atab\">岗位类别</td><td>" + strGWLB + "</td>" + "<td class=\"atab\">职称级别</td><td>"
        + strJobLevel + "</td></tr>"

        + "<tr><td class=\"atab\">部门职务</td><td>" + strUnitName + "&nbsp;" + strJobName + "</td>"
        + "<td class=\"atab\">职务级别</td><td>" + strGOVLevel + "</td></tr>"

        + "<tr><td class=\"atab\">专业技术<br />任职资格</td><td>" + strQualificationsName + "</td>"
        + "<td class=\"atab\">熟悉专业<br />有何专长</td><td>" + strExpertise + "</td></tr>"

        + "<tr><td class=\"atab\">简历</td><td colspan=\"3\">" + strResume + "</td></tr>";
    strHtml += "</table>";

    return strHtml;
  }

  // 设置家庭信息的html代码，暂不显示
  private String setHtmlFamily(int intBasicID) {
    List<Map<String, Object>> listInfo = null;
    Map<String, Object> mapInfo = null;
    InfoFamily objFamilyInfo = null;

    com.leaderinfo.dao.FamilyDao objFamilyDAO = new com.leaderinfo.dao.FamilyDao(strDBFile);

    listInfo = objFamilyDAO.getRecordsByBasicID(intBasicID);

    String strHtml = "<table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">"
        + "<tr><td colspan=\"5\" class=\"atitle\">家庭成员及重要社会关系</td></tr>"
        + "<tr><td width=\"15%\" class=\"atab\">称谓</td>" + "<td width=\"18%\" class=\"atab\">姓名</td>"
        + "<td width=\"18%\" class=\"atab\">出生日期</td>" + "<td width=\"18%\" class=\"atab\">政治面貌</td>"
        + "<td width=\"31%\" class=\"atab\">工作单位及职务</td>" + "</tr>";
    String strAppellation = "&nbsp;";
    String strRealName = "&nbsp;";
    String strBirthday = "&nbsp;";
    String strPoliticalAffiliation = "&nbsp;";
    String strWorkUnit = "&nbsp;";
    if (listInfo != null && listInfo.size() > 0) {
      for (int i = 0; i < listInfo.size(); i++) {
        mapInfo = listInfo.get(i);
        if (mapInfo != null) {
          objFamilyInfo = (InfoFamily) mapInfo.get("FamilyInfo");

          strAppellation = (objFamilyInfo.Appellation.equals("")) ? "&nbsp;" : objFamilyInfo.Appellation;
          strRealName = (objFamilyInfo.RealName.equals("")) ? "&nbsp;" : objFamilyInfo.RealName;
          strBirthday = (objFamilyInfo.Birthday.equals("")) ? "&nbsp;" : objFamilyInfo.Birthday;
          strPoliticalAffiliation = (objFamilyInfo.PoliticalAffiliation.equals("")) ? "&nbsp;"
              : objFamilyInfo.PoliticalAffiliation;
          strWorkUnit = (objFamilyInfo.WorkUnit.equals("")) ? "&nbsp;" : objFamilyInfo.WorkUnit;
        }
        strHtml += "<tr><td align=\"center\">" + strAppellation + "</td><td align=\"center\">" + strRealName
            + "</td><td align=\"center\">" + strBirthday + "</td><td align=\"center\">"
            + strPoliticalAffiliation + "</td><td>" + strWorkUnit + "</td></tr>";
      }
    }
    strHtml += "</table>";

    return strHtml;
  }

  // 设置单位信息的html代码
  private String setHtmlUnit(int intBasicID) {
    String strHtml = "<table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">"
        + "<tr><td colspan=\"6\" class=\"atitle\">工作单位经历</td></tr>"
        + "<tr><td width=\"17%\" class=\"atab\">任职单位</td>" + "<td width=\"17%\" class=\"atab\">职务</td>"
        + "<td width=\"17%\" class=\"atab\">职务层次</td>" + "<td width=\"17%\" class=\"atab\">任职时间</td>"
        + "<td width=\"16%\" class=\"atab\">专业技术职务</td>" + "<td width=\"16%\" class=\"atab\">技术职务任职时间</td>"
        + "</tr>";
    String strUnitName = "&nbsp;";
    String strJobName = "&nbsp;";
    String strWorkContent = "&nbsp;";
    String strHoldpostDate = "&nbsp;";
    String strQualificationsName = "&nbsp;";
    String strGetDate = "&nbsp;";

    InfoUnit objUnitInfo = new InfoUnit();
    com.leaderinfo.dao.UnitDao objUnitDAO = new com.leaderinfo.dao.UnitDao(strDBFile);
    com.leaderinfo.dao.UnitCategoryDao objUnitCategoryDAO = new com.leaderinfo.dao.UnitCategoryDao(strDBFile);

    InfoExpertise objExpertiseInfo = new InfoExpertise();
    com.leaderinfo.dao.ExpertiseDao objExpDAO = new com.leaderinfo.dao.ExpertiseDao(strDBFile);

    Map<String, Object> mapUnitInfo = objUnitDAO.getRecordByBasicID(intBasicID);
    Map<String, Object> mapExpertiseInfo = objExpDAO.getRecordByBasicID(intBasicID);

    if (mapUnitInfo != null) {
      objUnitInfo = (InfoUnit) mapUnitInfo.get("UnitInfo");
      if (objUnitInfo.UnitID > 0) {
        strUnitName = objUnitCategoryDAO.getUnitNameByID(objUnitInfo.UnitID);
      }
      strJobName = (objUnitInfo.JobName.equals("")) ? "&nbsp;" : objUnitInfo.JobName;
      strWorkContent = (objUnitInfo.WorkContent.equals("")) ? "&nbsp;" : objUnitInfo.WorkContent;
      strHoldpostDate = (objUnitInfo.HoldpostDate.equals("")) ? "&nbsp;" : objUnitInfo.HoldpostDate;
    }

    if (mapExpertiseInfo != null) {
      objExpertiseInfo = (InfoExpertise) mapExpertiseInfo.get("ExpertiseInfo");
      strQualificationsName = (objExpertiseInfo.QualificationsName.equals("")) ? "&nbsp;"
          : objExpertiseInfo.QualificationsName;
      strGetDate = (objExpertiseInfo.GetDate.equals("")) ? "&nbsp;" : objExpertiseInfo.GetDate;
    }

    strHtml += "<tr><td align=\"center\">" + strUnitName + "</td><td align=\"center\">" + strJobName
        + "</td><td align=\"center\">" + strWorkContent + "</td><td align=\"center\">" + strHoldpostDate
        + "</td><td align=\"center\">" + strQualificationsName + "</td><td align=\"center\">" + strGetDate
        + "</td></tr>";

    strHtml += "</table>";

    return strHtml;
  }

  // 设置学历信息的html代码
  private String setHtmlEdu(int intBasicID) {
    InfoEducation objEdu = new InfoEducation();
    com.leaderinfo.dao.EducationDao objEducationDAO = new com.leaderinfo.dao.EducationDao(strDBFile);

    List<Map<String, Object>> listEduInfo = objEducationDAO.getRecordsByBasicID(intBasicID);

    String strHtml = "<table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">"
        + "<tr><td colspan=\"5\" class=\"atitle\">学历学位信息</td></tr>" + "<tr>"
        + "<td width=\"20%\" class=\"atab\">教育<br />类别</td>" + "<td width=\"20%\" class=\"atab\">学历</td>"
        + "<td width=\"20%\" class=\"atab\">学位</td>" + "<td width=\"20%\" class=\"atab\">毕业<br />院校</td>"
        + "<td width=\"20%\" class=\"atab\">所学<br />专业</td>" + "</tr>";

    String strEducationType = "&nbsp;";
    String strEducation = "&nbsp;";
    String strEducationDegree = "&nbsp;";
    String strGraduateSchool = "&nbsp;";
    String strSpecialty = "&nbsp;";

    if (listEduInfo != null && listEduInfo.size() > 0) {
      for (int i = 0; i < listEduInfo.size(); i++) {
        mapInfo = listEduInfo.get(i);
        if (mapInfo != null) {
          objEdu = (InfoEducation) mapInfo.get("EducationInfo");

          strEducationType = (objEdu.EducationType.equals("")) ? "&nbsp;" : objEdu.EducationType;
          strEducation = (objEdu.Education.equals("")) ? "&nbsp;" : objEdu.Education;
          strEducationDegree = (objEdu.EducationDegree.equals("")) ? "&nbsp;" : objEdu.EducationDegree;
          strGraduateSchool = (objEdu.GraduateSchool.equals("")) ? "&nbsp;" : objEdu.GraduateSchool;
          strSpecialty = (objEdu.Specialty.equals("")) ? "&nbsp;" : objEdu.Specialty;
        }
        strHtml += "<tr><td align=\"center\">" + strEducationType + "</td><td align=\"center\">" + strEducation
            + "</td><td align=\"center\">" + strEducationDegree + "</td><td align=\"center\">"
            + strGraduateSchool + "</td><td align=\"center\">" + strSpecialty + "</td></tr>";
      }
    }
    strHtml += "</table>";
    return strHtml;
  }

  // 读取学历信息
  private String[] GetEduInfo(int intBasicID) {
    String[] aryEduInfo = new String[]{"", ""};

    InfoEducation objEdu = new InfoEducation();
    com.leaderinfo.dao.EducationDao objEducationDAO = new com.leaderinfo.dao.EducationDao(strDBFile);

    List<Map<String, Object>> listEduInfo = objEducationDAO.getRecordsByBasicID(intBasicID);

    if (listEduInfo != null && listEduInfo.size() > 0) {
      for (int i = 0; i < listEduInfo.size(); i++) {
        mapInfo = listEduInfo.get(i);
        if (mapInfo != null) {
          objEdu = (InfoEducation) mapInfo.get("EducationInfo");
          if (i == 0) {
            aryEduInfo[0] = objEdu.Education;
          } else if (i == 1) {
            aryEduInfo[1] = objEdu.Education;
          }
        }
      }
    }
    return aryEduInfo;
  }

  private String GetJobLevelName(int intJobLevelID) {
    String strReturn = "";
    if (intJobLevelID == 1)
      strReturn = "教授级";
    else if (intJobLevelID == 2)
      strReturn = "副教授级";
    else if (intJobLevelID == 3)
      strReturn = "讲师级";
    else if (intJobLevelID == 4)
      strReturn = "助理级";
    return strReturn;
  }

  private String GetGOVLevelName(String strGOVLevelID) {
    String strReturn = "";
    if (strGOVLevelID.equals("1"))
      strReturn = "管理十级(员级)";
    else if (strGOVLevelID.equals("2"))
      strReturn = "管理九级(科员级)";
    else if (strGOVLevelID.equals("3"))
      strReturn = "管理八级(副科级)";
    else if (strGOVLevelID.equals("4"))
      strReturn = "管理七级(正科级)";
    else if (strGOVLevelID.equals("5"))
      strReturn = "管理六级(副处级)";
    else if (strGOVLevelID.equals("6"))
      strReturn = "管理五级(正处级)";
    else if (strGOVLevelID.equals("7"))
      strReturn = "管理四级(副局级)";
    return strReturn;
  }

  // 如果不做任何处理，浏览网页，点击系统“Back”键，整个Browser会调用finish()而结束自身，如果希望浏览的网
  // 页回退而不是推出浏览器，需要在当前Activity中处理并消费掉该Back事件。
  @Override
  public boolean onKeyDown(int intKeyCode, KeyEvent objKeyEvent) {
    if ((intKeyCode == KeyEvent.KEYCODE_BACK) && objWV.canGoBack()) {
      objWV.goBack();
      return true;
    }
    return super.onKeyDown(intKeyCode, objKeyEvent);
  }

  @Override
  public void onClick(View v) {
    int id = v.getId();
    if (id == R.id.imgbtnFavorite) {
      int intResult = 0;
      com.leaderinfo.dao.PartyInfoDao objDaoPartyInfo = new com.leaderinfo.dao.PartyInfoDao(strDBFile);
      intResult = objDaoPartyInfo.setFavorite(intAID);
      if (intResult > 0) {
        if (objDaoPartyInfo.getFavoriteFlag(intAID) == 0) {
          imgbtnFavorite.setImageDrawable(this.getResources().getDrawable(R.drawable.bgbtn_favorite_add));
        } else {
          imgbtnFavorite.setImageDrawable(this.getResources().getDrawable(R.drawable.bgbtn_favorite_cancel));
        }
      }
    }
  }

}